<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta name="screen-orientation" content="portrait">
    <meta name="x5-orientation" content="portrait">
    <meta name="full-screen" content="yes">
    <meta name="x5-fullscreen" content="true">
    <title>正常打款明细</title>
    <link rel="stylesheet" href="../../styles/h5/reset.min.css"/>
    <link rel="stylesheet" href="../../styles/h5/errortankuang.css"/>
    <!--以上为公共css样式-->
    <link rel="stylesheet" href="../../styles/h5/index.css"/>
    <link rel="stylesheet" href="../../styles/h5/dropload.css"/>

    <script charset="utf-8" type="text/javascript" src="../../scripts/h5/jquery-1.9.1.min.js"></script>
    <script charset="utf-8" type="text/javascript" src="../../scripts/h5/jquery.modal.js"></script>
    <!--以上为公共js文件-->
</head>
<body>
<div class="zz-date-header">
    <ul class="zz-flex" style="border: none">
        <li class="zz-h88">打款日期</li>
        <li class="zz-h88">打款金额</li>
        <li class="zz-h88">到账银行</li>
    </ul>
</div>
<div class="zz-date-list">
    <!--<ul class="zz-flex">
        <li class="zz-h130">03-29</li>
        <li class="zz-h130">
            ￥10.00
            &lt;!&ndash;<span class="zz-money-weight zz-padding-top">￥10.00</span>&ndash;&gt;
        </li>
        <li class="zz-h130">
            <span class="zz-padding-top zz-maxWidth-bank">民生银行</span>
            <span class="zz-bank-success flr">尾号(8888)</span>
        </li>
    </ul>-->
</div>

<!--<input type="button" class="zz-look-more" value="加载更多"/>-->
</body>
<script charset="utf-8" type="text/javascript" src="../../scripts/h5/utils.js"></script>
<script charset="utf-8" type="text/javascript" src="../../scripts/h5/index.js"></script>
<script charset="utf-8" type="text/javascript" src="../../scripts/h5/dropload.min.js"></script>
<script charset="utf-8" type="text/javascript">
    var queryURLParameter = utils.queryURLParameter();
    var merId = queryURLParameter.merId;
    // 第几页
    var currentPage = 0;
    // 每页展示20个
    var pageNo = 20;
    // 加载的最少条数
    var pageNum = 20;
    var data = '';
    var result = '';
    var timer = '';
    var $date_list = $('.zz-date-list');
    function bindHTML() {
        result = '';
        for (var i = 0; i < data.resultList.length; i++) {
            var curData = data.resultList[i];
            var kahao = utils.cutOut(curData.inMediaId);
            result += '<ul class="zz-flex">'
                    + '<li class="zz-h130">' + curData.inTime + '</li>'
                    + '<li class="zz-h130">￥' + curData.amount + '</li>'
                    + '<li class="zz-h130">'
                    + '<span class="zz-padding-top zz-maxWidth-bank">' + curData.bankName + '</span>'
                    + '<span class="zz-bank-success flr">尾号(' + kahao + ')</span>'
                    + '</li>'
                    + '</ul>'
        }
    }
    //下拉刷新 ajax回调函数
    function loadUp(me) {
        // 为了测试，延迟1秒加载
        clearTimeout(timer);
        timer = setTimeout(function () {
        	$date_list.html(result);
           	//每次数据加载完，必须重置
            me.resetload();
            
            if (data.resultList.length < pageNum) {
                // 锁定
                me.lock("down");
                // 无数据
                //me.noData(true);
                
                $(".dropload-refresh").html("暂无数据").css("color", "#999");
                $(".dropload-noData").html("暂无数据").css("color", "#999");
            } else {
            	// 解锁
                me.unlock();
                $(".dropload-refresh").html("↑上拉加载更多").css("color", "#333");
                $(".dropload-noData").html("↑上拉加载更多").css("color", "#333");
                //有数据
                //me.noData(false);
            }
            
        }, 500);
    }
    //上拉加载 ajax回调函数
    function loadDown(me) {

		if (data.resultList.length < pageNum) {
        	// 锁定
            me.lock();
            //me.lock("down");
            // 无数据
            me.noData(true);
            //$(".dropload-refresh").html("暂无数据").css("color", "#999");
        }else{
        	me.unlock();
        	me.noData(false);
        }
        
        clearTimeout(timer);
        timer = setTimeout(function () {
            $date_list.children("ul:last-child").css("border-bottom", "1px solid #dcdcdc");
            $date_list.append(result);
            // 每次数据加载完，必须重置
            me.resetload();
        }, 500);
    }

    //下拉刷新 上拉加载 ajax
    function ajaxList(callback, me) {
        $.ajax({
            type: 'GET',
            url: utils.ajaxUrl()+"h5/queryPayController/queryRevPayOrder",
            data: {
                pageNo: pageNo,
                currentPage: currentPage,
                merId: merId
            },
            dataType: 'json',
            success: function (res) {
                //var data = JSON.parse(res);
                data = res;
                console.log(res);
                if (data.retCode == "0000") {
                    bindHTML();
                    if (callback != undefined) {
                        callback(me);
                    }
                } else {
                	me.lock();
                	me.noData(true);
                    utils.newModalPrompt(data.retMsg);
                    me.resetload();
                    
                    
                }
            },
            error: function (xhr, type) {
                utils.newModalPrompt("失败");
                // 即使加载出错，也得重置
                if (me != undefined) {
                	me.lock();
                	me.noData(true);
                    me.resetload();
                }
            }
        });
    }

    $(function () {
        // dropload
        $('body').dropload({
            scrollArea: window,
            domUp: {
                domClass: 'dropload-up',
                domRefresh: '<div class="dropload-refresh">↓下拉刷新</div>',
                domUpdate: '<div class="dropload-update">↑释放更新</div>',
                domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>'
            },
            domDown: {
                domClass: 'dropload-down',
                domRefresh: '<div class="dropload-refresh">↑上拉加载更多</div>',
                domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
                domNoData: '<div class="dropload-noData">暂无数据</div>'
            },
            // 下拉刷新
            loadUpFn: function (me) {
                // 第一页
                currentPage = 1;
//                console.log(currentPage);
                ajaxList(loadUp, me);
            },
//            上拉加载 和初始化
            loadDownFn: function (me) {
//                页数累加
                currentPage++;
//                console.log(currentPage);
                ajaxList(loadDown, me);
            },
            distance:50,
            threshold:3
        });
    });
</script>
</html>